
/*
 *
 * Copyright (c) 2006 P.J.Leonard
 * 
 * http://www.frinika.com
 * 
 * This file is part of Frinika.
 * 
 * Frinika is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.

 * Frinika is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with Frinika; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
package uk.ac.bath.domains.IP;

import uk.ac.bath.base.MachineIF;

/**
 *
 * @author pjl
 */
public class IPSetupQuadVert implements IPSetupIF {

    float one_degree = 0.0174532f;	/* 2pi/360 */

    float six_degrees = 0.1047192f;
    float twelve_degrees = 0.2094384f;
    float fifty_degrees = 0.87266f;

    @Override
    public CartSimIF newCartSim(MachineIF net) {
        return new CartSimQuad(net, 0.0f, 0.0f, (float)Math.PI, 0.0f);
    }

    @Override
    public int getNIn() {
        return 6;
    }

    public int getNOut() {
        return 2;
    }

    public boolean hasFailed(CartSimIF sim) {
        IPModelIF model = sim.getModel();
        /*--- Check for failure.  If so, return steps ---*/
        if (!model.isOverriden()) {
            if (model.getX() < -10.0 || model.getX() > 10.0) {
                return true;
            }

            if (sim.getStepCount() > 500) {
                double cosT = Math.cos(model.getPhi());
                if (cosT < 0.0) {
                    return true;
                }
            }
        }
        return false;
    }

    public String reportSetup() {
        return " IP with quadriture sensor ";
    }
}
